<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1"><title id="kw142714">gplogfilter</title><body><p>Searches through Greenplum Database log files for specified entries.</p><section id="section2"><title>Synopsis</title><codeblock>gplogfilter [&lt;timestamp_options>] [&lt;pattern_options>] 
     [&lt;output_options>] [&lt;input_options>] [&lt;input_file>] 

gplogfilter --help 

gplogfilter --version</codeblock></section><section id="section3"><title>Description</title><p>The <codeph>gplogfilter</codeph> utility can be used to search through a Greenplum Database log file for entries matching the specified criteria. If an input
        file is not supplied, then <codeph>gplogfilter</codeph> will use the
          <codeph>$MASTER_DATA_DIRECTORY</codeph> environment variable to locate the Greenplum master log file in the standard logging location. To read
        from standard input, use a dash (<codeph>-</codeph>) as the input file name. Input files may
        be compressed using <codeph>gzip</codeph>. In an input file, a log entry is identified by
        its timestamp in <codeph>YYYY-MM-DD [hh:mm[:ss]]</codeph> format.</p><p>You can also use <codeph>gplogfilter</codeph> to search through all segment log files at once by
        running it through the <xref href="./gpssh.xml#topic1" type="topic" format="dita"/> utility.
        For example, to display the last three lines of each segment log file:</p><codeblock>gpssh -f seg_host_file
=&gt; source /usr/local/greenplum-db/greenplum_path.sh
=&gt; gplogfilter -n 3 /gpdata/*/pg_log/gpdb*.csv</codeblock><p>By default, the output of <codeph>gplogfilter</codeph> is sent to standard
output. Use the <codeph>-o</codeph> option to send the output to a file
or a directory. If you supply an output file name ending in <codeph>.gz</codeph>,
the output file will be compressed by default using maximum compression.
If the output destination is a directory, the output file is given the
same name as the input file.</p></section><section id="section4"><title>Options</title><sectiondiv id="section5"><b>Timestamp Options</b><parml><plentry><pt>-b <varname>datetime</varname> | --begin=<varname>datetime</varname></pt><pd>Specifies a starting date and time to begin searching for log entries
in the format of <codeph>YYYY-MM-DD [hh:mm[:ss]]</codeph>.</pd><pd>If a time is specified, the date and time must be enclosed in either
single or double quotes. This example encloses the date and time in single
quotes:</pd><pd><codeblock>gplogfilter -b '2013-05-23 14:33'</codeblock></pd></plentry><plentry><pt>-e <varname>datetime</varname> | --end=<varname>datetime</varname></pt><pd>Specifies an ending date and time to stop searching for log entries
in the format of <codeph>YYYY-MM-DD [hh:mm[:ss]]</codeph>.</pd><pd>If a time is specified, the date and time must be enclosed in either
single or double quotes. This example encloses the date and time in single
quotes: </pd><pd><codeblock>gplogfilter -e '2013-05-23 14:33' </codeblock></pd></plentry><plentry><pt>-d&lt;time> | --duration=&lt;time></pt><pd>Specifies a time duration to search for log entries in the format
of <codeph>[hh][:mm[:ss]]</codeph>. If used without either the <codeph>-b</codeph>
or <codeph>-e</codeph> option, will use the current time as a basis.</pd></plentry></parml></sectiondiv><sectiondiv id="section6"><b>Pattern Matching Options</b><parml><plentry><pt>-c i [gnore] | r [espect] | --case=i [gnore] | r [espect]</pt><pd>Matching of alphabetic characters is case sensitive by default unless
proceeded by the <codeph>--case=ignore</codeph> option.</pd></plentry><plentry><pt>-C '<varname>string</varname>' | --columns='<varname>string</varname>'</pt><pd>Selects specific columns from the log file. Specify the desired columns as a comma-delimited
              string of column numbers beginning with 1, where the second column from left is 2, the
              third is 3, and so on. <ph>See "Viewing the Database Server Log
                Files" in the <i>Greenplum Database Administrator Guide</i> for details about the
                log file format and for a list of the available columns and their associated
                number.</ph></pd></plentry><plentry><pt>-f '<varname>string</varname>' | --find='<varname>string</varname>'</pt><pd>Finds the log entries containing the specified string.</pd></plentry><plentry><pt>-F '<varname>string</varname>' | --nofind='<varname>string</varname>'</pt><pd>Rejects the log entries containing the specified string.</pd></plentry><plentry><pt>-m <varname>regex</varname> | --match=<varname>regex</varname></pt><pd>Finds log entries that match the specified Python regular expression.
See <xref href="https://docs.python.org/library/re.html" scope="external" format="html">https://docs.python.org/library/re.html</xref>
for Python regular expression syntax.</pd></plentry><plentry><pt>-M <varname>regex</varname> | --nomatch=<varname>regex</varname></pt><pd>Rejects log entries that match the specified Python regular expression.
See <xref href="https://docs.python.org/library/re.html" scope="external" format="html">https://docs.python.org/library/re.html</xref>
for Python regular expression syntax.</pd></plentry><plentry><pt>-t | --trouble</pt><pd>Finds only the log entries that have <codeph>ERROR:</codeph>, <codeph>FATAL:</codeph>,
or <codeph>PANIC:</codeph> in the first line.</pd></plentry></parml></sectiondiv><sectiondiv id="section7"><b>Output Options</b><parml><plentry><pt>-n &lt;integer> | --tail=&lt;integer></pt><pd>Limits the output to the last &lt;integer> of qualifying log entries found.</pd></plentry><plentry><pt>-s &lt;offset> [limit] | --slice=&lt;offset> [limit]</pt><pd>From the list of qualifying log entries, returns the &lt;limit> number of entries starting at
              the &lt;offset> entry number, where an &lt;offset> of zero (<codeph>0</codeph>)
              denotes the first entry in the result set and an &lt;offset> of any number greater
              than zero counts back from the end of the result set.</pd></plentry><plentry><pt>-o &lt;output_file> | --out=&lt;output_file></pt><pd>Writes the output to the specified file or directory location instead
of <codeph>STDOUT</codeph>. </pd></plentry><plentry><pt>-z 0-9 | --zip=0-9</pt><pd>Compresses the output file to the specified compression level using
<codeph>gzip</codeph>, where <codeph>0</codeph> is no compression and
<codeph>9</codeph> is maximum compression. If you supply an output file
name ending in <codeph>.gz</codeph>, the output file will be compressed
by default using maximum compression.</pd></plentry><plentry><pt>-a | --append</pt><pd>If the output file already exists, appends to the file instead of
overwriting it.</pd></plentry></parml></sectiondiv><sectiondiv id="section8"><b>Input Options</b><parml><plentry><pt>input_file</pt><pd>The name of the input log file(s) to search through. If an input file is not supplied,
                <codeph>gplogfilter</codeph> will use the <codeph>$MASTER_DATA_DIRECTORY</codeph>
              environment variable to locate the Greenplum Database master log file.
              To read from standard input, use a dash (<codeph>-</codeph>) as the input file
              name.</pd></plentry><plentry><pt>-u | --unzip</pt><pd>Uncompress the input file using <codeph>gunzip</codeph>. If the input
file name ends in <codeph>.gz</codeph>, it will be uncompressed by default.</pd></plentry><plentry><pt>--help</pt><pd>Displays the online help.</pd></plentry><plentry><pt>--version</pt><pd>Displays the version of this utility.</pd></plentry></parml></sectiondiv></section><section id="section9"><title>Examples</title><p>Display the last three error messages in the master log file:</p><codeblock>gplogfilter -t -n 3</codeblock><p>Display all log messages in the master log file timestamped in the last
10 minutes:</p><codeblock>gplogfilter -d :10</codeblock><p>Display log messages in the master log file containing the string <codeph>|con6
cmd11|</codeph>:</p><codeblock>gplogfilter -f '|con6 cmd11|'</codeblock><p>Using <xref href="./gpssh.xml#topic1" type="topic" format="dita"/>, run
          <codeph>gplogfilter</codeph> on the segment hosts and search for log messages in the
        segment log files containing the string <codeph>con6</codeph> and save output to a file.</p><codeblock>gpssh -f seg_hosts_file -e 'source 
/usr/local/greenplum-db/greenplum_path.sh ; gplogfilter -f 
con6 /gpdata/*/log/gpdb*.csv' &gt; seglog.out</codeblock></section><section id="section10"><title>See Also</title><p><xref href="./gpssh.xml#topic1" type="topic" format="dita"/>, <xref href="./gpscp.xml#topic1"
          type="topic" format="dita"/></p></section></body></topic>
